//
// Created by Yurzi on 2021/3/21.
//

#ifndef CEDUGROUPWORK_DATATYPES_H
#define CEDUGROUPWORK_DATATYPES_H
#include <stdbool.h>
#include "GlobalDefinitions.h"
#include <time.h>

#define MAX_NAMELENGTH_KTM 26
#define MAX_NAMELENGTH_G 26
#define MAX_LABELSIZE 10
#define MAX_CARSIZE 20

//原料
typedef struct material
{
    int materialId; //原料id
    char materialName[MAX_NAMELENGTH_KTM];  //原料名称
    int amount; //原料储存量
    double price;//原料价格
    struct material* next;//下一个原料
}Material;

//标签
typedef struct tag
{
    int tagId;  //标签ID
    char tagName[MAX_NAMELENGTH_KTM];   //标签名称
    Material materials[MAX_LABELSIZE]; //标签所需原料
    double price;//标签所需价格
    struct tag* next;//下一个标签
}Tag;

//商品结构体
typedef  struct good
{
    int kindId; //商品所属类ID
    int goodId; //商品id
    char goodName[MAX_NAMELENGTH_G]; //商品名称
    double price;  //商品基准价格
    bool ice,hot;//商品是否可以加冰，加热
    double big, sbig;//定义商品大杯与超大杯
    Tag tags[MAX_LABELSIZE];   //商品标签
    Material materials[MAX_LABELSIZE]; //商品原材料
    struct good*  next;
}Good;

//购物车中商品对象
typedef struct car
{
    int goodId;//商品ID
    int kindId; //商品所属类ID
    double price;//商品价格
    Material materials[MAX_CARSIZE]; //商品原材料
    int ioh;//商品是否加冰，加热//常温(1) 冷(2) 热(3)
    int size;//规格
    double capacity;//具体大小
    Tag condiment[MAX_LABELSIZE];//佐料
    int amount;
    struct car* next;//下一个商品
}Car;

//商品类结构体
typedef struct kind
{
    int kindId; //类id
    char kindName[MAX_NAMELENGTH_KTM]; //类名
    struct kind* next; //下一个类
    Good* child;    //类下商品
}Kind;

//二元对
typedef struct binarypair{
    double x; //天
    double y;  //销量
    struct binarypair *next,*prv;
}BinaryPair;


//商品书页
typedef struct goodPage{
    int pageId;
    int count;
    struct goodPage *prv;
    struct goodPage *next;
    Good *item[ONEPAGE_ITEMS];
}GoodPage;

//类书页
typedef struct kindPage{
    int pageId;
    int count;
    struct kindPage *prv;
    struct kindPage *next;
    Kind *item[ONEPAGE_ITEMS];
}KindPage;

//标签书页
typedef struct tagPage{
    int pageId;
    int count;
    struct tagPage *prv;
    struct tagPage *next;
    Tag *item[ONEPAGE_ITEMS];
}TagPage;

//原料书页
typedef struct mtPage{
    int pageId;
    int count;
    struct mtPage *prv;
    struct mtPage *next;
    Material *item[ONEPAGE_ITEMS];
}MTPage;

//历史节点
typedef struct lognode{
    time_t time;
    Car content;
    struct lognode *prv;
    struct lognode *next;
}LogNode;

//历史书页
typedef struct logPage{
    int pageId;
    int count;
    struct logPage *prv;
    struct logPage *next;
    LogNode *item[ONEPAGE_ITEMS];
}LogPage;

#endif //CEDUGROUPWORK_DATATYPES_H
